﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Model;
using Controller;

namespace Biffen
{
    public partial class MainUI : Form
    {

        private EmployeeCtr empCtr = new EmployeeCtr();

        // Starting this controller to make a connection to the webservice, all other webservices will load faster
        private DialUpCtr dialCtr = new DialUpCtr();

        public MainUI()
        {
            InitializeComponent();
            if (!dialCtr.HaveConnection())
            {
                MessageBox.Show("FEJL! Der er ingen forbindelse til Webservicen, og programmet vil derfor ikke kunne starte.", "Webservice fejl!");
                base.Dispose();
                Dispose();
            }
        }

        private void Main_Load(object sender, EventArgs e)
        {
            CurrentFilmsUI cFilms = new CurrentFilmsUI();
            cFilms.MdiParent = this;
            cFilms.Show();
        }

        private void button1_Click(object sender, EventArgs e)
        {

        }

        private void button1_Click_1(object sender, EventArgs e)
        {
            foreach (Form md in this.MdiChildren)
            {
                md.Hide();
            }
            CurrentFilmsUI cFilms = new CurrentFilmsUI();
            cFilms.MdiParent = this;
            cFilms.Show();
            ResizeFrom();
        }

        private void button9_Click(object sender, EventArgs e)
        {
            foreach (Form md in this.MdiChildren)
            {
                md.Hide();
            }
        }

        private void button6_Click(object sender, EventArgs e)
        {
            foreach (Form md in  this.MdiChildren)
            {
                md.Hide();
            }
          
            BookingUI book = new BookingUI();
            book.MdiParent = this;
            book.Show();
            ResizeFrom();
        }

        private void Main_SizeChanged(object sender, EventArgs e)
        {
            ResizeFrom();
            //System.Console.Out.WriteLine("Form size: Widht:" +this.Size.Width + " Height:" +this.Size.Height );
        }
        public void ResizeFrom()
        {
            foreach (Form md in this.MdiChildren)
            {
                md.Height = this.Size.Height - 45;
                md.Width = this.Size.Width - 23;
            }
        }

        private void btnOverview_Click(object sender, EventArgs e)
        {
            foreach (Form md in this.MdiChildren)
            {
                md.Hide();
            }
            OverviewUI oView = new OverviewUI();
            oView.MdiParent = this;
            oView.Show();
            ResizeFrom();
        }

        private void btnSearch_Click(object sender, EventArgs e)
        {
            foreach (Form md in this.MdiChildren)
            {
                md.Hide();
            }
            SearchUI search = new SearchUI();
            search.MdiParent = this;
            search.Show();
            ResizeFrom();
        }

        private void btnMovie_Click(object sender, EventArgs e)
        {
            foreach (Form md in this.MdiChildren)
            {
                md.Hide();
            }
            MovieUI movie = new MovieUI();
            movie.MdiParent = this;
            movie.Show();
            ResizeFrom();
        }

        private void btnEmployee_Click(object sender, EventArgs e)
        {
            foreach (Form md in this.MdiChildren)
            {
                md.Hide();
            }
            EmployeeUI emp = new EmployeeUI();
            emp.MdiParent = this;
            emp.Show();
            ResizeFrom();
        }

        private void btnMember_Click(object sender, EventArgs e)
        {
            foreach (Form md in this.MdiChildren)
            {
                md.Hide();
            }
            MembersUI member = new MembersUI();
            member.MdiParent = this;
            member.Show();
            ResizeFrom();
        }
        
    }
}
